{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">发布人</label>
                    <div class="layui-input-block">
                        <input type="text" name="realname" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">审核状态</label>
                    <div class="layui-input-block">
                        <select name="status">
                            <option>全部</option>
                            <option value="0">审核中</option>
                            <option value="1">审核通过</option>
                            <option value="2">审核不通过</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">认领状态</label>
                    <div class="layui-input-block">
                        <select name="order_status">
                            <option>全部</option>
                            <option value="0">未认领</option>
                            <option value="1">已认领</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="batchdel">删除</button>
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="add">添加</button>
            </div>
            <script type="text/html" id="statusTpl">
                {{#  if(d.status == 1){ }}
                <a class="layui-btn layui-btn-normal layui-btn-xs">审核通过</a>
                {{#  } else if(d.status == 2){ }}
                <a class="layui-btn layui-btn-danger layui-btn-xs">审核不通过</a>
                {{#  } else { }}
                <a class="layui-btn layui-btn-normal layui-btn-xs">审核中</a>
                {{#  } }}
            </script>
            <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
            <script type="text/html" id="iconTpl">
                <img style="display: inline-block; width: 50%; height: 100%;" src={{ d.icon }}>
            </script>
            <script type="text/html" id="orderTpl">
                {{#  if(d.order_status == 1){ }}
                <a class="layui-btn layui-btn-normal layui-btn-xs">已认领</a>
                {{#  } else { }}
                <a class="layui-btn layui-btn-danger layui-btn-xs">未认领</a>
                {{#  } }}
            </script>
            <script type="text/html" id="table-useradmin-webuser">
                {{#  if(d.order_status == 1){ }}
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="apply">认领列表</a>
                {{#} }}
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i
                        class="layui-icon layui-icon-edit"></i>编辑</a>
                <!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i-->
                        <!--class="layui-icon layui-icon-delete"></i>删除</a>-->
            </script>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table;

        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            var field = data.field;
            //执行重载
            table.reload('LAY-user-manage', {
                where: field
                ,page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        //用户管理
        table.render({
            elem: '#LAY-user-manage'
            , url: "{:url('wish/ajaxIndex')}" //模拟接口
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', width: 100, title: 'ID', sort: true}
                , {field: 'title', title: '心愿标题', minWidth: 100}
                , {field: 'realname', title: '心愿发布人', minWidth: 100}
                // , {field: 'mobile', title: '家庭情况', minWidth: 100}
                , {field: 'street_name', title: '所属街镇', minWidth: 100}
                , {field: 'village', title: '所在村居', minWidth: 100}
                , {field: 'v_mobile', title: '志愿者联系方式', minWidth: 100}
                , {field: 'status', title: '审核状态', toolbar:'#statusTpl'}
                , {field: 'order_status', title: '认领状态', toolbar:'#orderTpl'}
                , {field: 'create_time', title: '添加时间', sort: true,}
                , {title: '操作', width:180, align: 'center', fixed: 'right', toolbar: '#table-useradmin-webuser'}
            ]]
            , method: 'post'
            , page: true
            , limit: 20
            , height: 'full-180'
            , text: '对不起，加载出现异常！'
        });

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            var url = "";
            if (type == 'add') {
                url = "{:url('wish/add')}";
            }
            active[type] ? active[type].call(this, url, table) : '';
        });
    });
</script>
</body>
</html>
{/block}
